package com.ruoyi.common.pms.dao;

import com.ruoyi.common.pms.entity.YytPmsSkuSaleAttrValue;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * sku销售属性&值 Mapper 接口
 * </p>
 *
 * @author huangshun
 * @since 2021-12-16
 */
@Repository
public interface YytPmsSkuSaleAttrValueMapper extends BaseMapper<YytPmsSkuSaleAttrValue> {

    /**
     * 根据spuId获取商品规格属性列表
     */
    @Select("select attr.* from yyt_pms_sku_info sku, yyt_pms_sku_sale_attr_value attr where sku.spu_id = #{spuId} and " +
            "sku.sku_id = attr.sku_id order by attr.attr_name")
    List<YytPmsSkuSaleAttrValue> listBySpuId(@Param("spuId") String spuId);

    /**
     * 根据skuId获取对应的商品规格属性
     */
    @Select("select * from yyt_pms_sku_sale_attr_value where sku_id = #{skuId}")
    YytPmsSkuSaleAttrValue getBySkuId(@Param("skuId") String skuId);

}
